/*
 * copyright (c) 2013 Blaise-Florentin Collin
 *
 * This file is part of astroDCAM.
 *
 * AstroAviBrowser is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License v3
 * as published by the Free Software Foundation
 *
 * AstroAviBrowser is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * v3 along with AstroAviBrowser; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 */

///
/// \file dc1394bus.hpp
///
/// \brief Object wrapper for the dc1394 api (bus part) (headers)
///

#ifndef _DC1394BUS_HPP_
#define _DC1394BUS_HPP_

// C++ includes
#include <vector>

// libdc1394 includes
#include <dc1394/dc1394.h>

// C++ app includes
#include "dc1394error.hpp"
#include "dc1394camera.hpp"

///
/// \class dc1394bus
///
/// \brief Object wrapper for the dc1394 api (bus part)
///
class dc1394bus {
   public :
      /// Main constructor
      dc1394bus();
      /// Main destructor
      ~dc1394bus();
      /// Reset the bus
      void reset();
      /// Number of cameras on the bus
      int getCameraNumber();
      /// Camera's list
      std::vector<dc1394cameraId> getCameraList() { return(cameraList); }
      /// Create, init and return a new camera object (must be released by user), NULL if failed
      dc1394camera* getCamera(uint64_t guid);
      /// Release camera
      void releaseCamera(dc1394camera* cam) { delete cam; }
      /// Is the bus ready ?
      bool isReady() { return(bus_handler!=NULL); }
   private :
      // dc1394 stuff
      dc1394_t* bus_handler; ///< Pointer on the bus structure
      dc1394camera_list_t* camera_list; ///< Store the camera list
      std::vector<dc1394cameraId> cameraList; ///< List of cameras IDs

      // private methods
      /// Clear the bus
      void clear();
      /// Init the bus
      void init();
};

#endif
